/**
 * Created by sxx on 2017/7/14.
 */
import "./index.less";
import httpurl from "../../../unit/common/js/httpurl";
import chrmDetailTpl from "./chrm_detail.handlebars";


jQuery(function () {
    App.init();

    var id = httpurl.uri.params.id;
    let token = sessionStorage.getItem('supplier_token');

    jQuery.ajax({
        url: HOST_ADDR + '/cpmp/splrSlfMng/chrm/' + id,
        type: 'get',
        dataType: 'json',
        contentType:"application/json",
        access_token: token,
        headers: {
            'access_token': token,
            'login_type': 'splr'
        },
        success: function(resp){
            if (!resp.success || resp.msgCod !=='S0002') {
                alert(resp.msgCod+' '+resp.msgInf);

                let detailHtml = chrmDetailTpl(resp.data);
	        $('.basicInfo').html(detailHtml);
                $(document).on('click', '.J_cancel', function(){
		    location.href = '/supplier_self/supplier_chrm.html';
                });

                return;
            }
	    resp.data.imgFmt = HOST_ADDR + '/' + resp.data.chrmIcon;
	    console.log(resp.data.imgFmt);
	    let detailHtml = chrmDetailTpl(resp.data);
	    $('.basicInfo').html(detailHtml);
            $(document).on('click', '.J_cancel', function(){
		location.href = '/supplier_self/supplier_chrm.html';
            });
        },
        error:function(err){
            console.log(err);
        }
    });
});
